/**
 * 
 */
package org.universalmvc.config;

import org.universalmvc.util.CollectionsUtil;



/**
 * @author vj
 *
 */
public class Configuration {
	private Application application;
	
	public Configuration() {
	}
	
	public Configuration(Application application) {
		this.application = application;
	}
	
	/**
	 * @return the application
	 */
	public Application getApplication() {
		return application;
	}

	/**
	 * @param application the application to set
	 */
	public void setApplication(Application application) {
		this.application = application;
	}

	public void merge(final Configuration config) {
		if((config != null) && (config.getApplication() != null)) {
			Application app = config.getApplication();
			if(application == null) {
				application = app;
			} else {
				application.setModels(new CollectionsUtil<Model>().append(application.getModels(), app.getModels()));
				application.setViews(new CollectionsUtil<View>().append(application.getViews(), app.getViews()));
				application.setControllers(new CollectionsUtil<Controller>().append(application.getControllers(), app.getControllers()));
			}
		}
	}
}
